﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using DreamBuilder.Common;
using DreamBuilder.Core.DAO;
using CommonModule;

namespace Web.SystemConfig.DataAccess
{
    public class DALUserRoleFunction : DataAccessBase
    {
        public  DALUserRoleFunction ()
        {
            DBHelper = DBHelperFactory.CreateInstance(DBHelperString.Dictionary);
        }
        internal DataTable SelectFunctionsTableByUserID(string UserID)
        {
            string sqlstr = @"SELECT  Distinct Func_Code FROM P_Auth_Function WHERE  
             Func_ID in(  
                 select Func_ID from P_Auth_Role_Function   
                 where Role_ID in  
                  (select Role_ID from P_Auth_User_Role where User_ID='{0}')  
      )";
            sqlstr = string.Format(sqlstr, UserID);
            return DBHelper.ExecuteDataSet(sqlstr).Tables[0];
        }

        internal DataTable GetCreateByField(string menuID)
        {
            string sqlstr = "SELECT Create_Columm FROM P_Auth_Menu WHERE Menu_ID = '" + menuID + "' ";
            return DBHelper.ExecuteDataSet(sqlstr).Tables[0];
        }

        internal DataTable GetEncryptColumnFields(string menuID)
        {
            string sqlstr = "SELECT Filter_Columm_Str FROM P_Auth_Menu WHERE Menu_ID = '" + menuID + "' ";
            return DBHelper.ExecuteDataSet(sqlstr).Tables[0];
        }
    }
}